package com.hq.door.dto;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import com.hq.door.pojo.TInstitute;
import com.hq.door.pojo.TMajor;

/**
 * 作者：袁健宝
 * 日期：2016年12月30日 上午4:01:54
 */
public class MajorDto {
	
	public static Major writeMajor(TMajor tmajor){
		Major major = new Major();
	    if (tmajor != null){
	    	major.setId(tmajor.getId());
	    	major.setTInstitute(tmajor.getTInstitute());
	    	major.setName(tmajor.getName());
	    	major.setCode(tmajor.getCode());
	    	major.setModifiedTime(tmajor.getModifiedTime());
	    	major.setModifiedBy(tmajor.getModifiedBy());
	    }
	    return major;
    }
	
	
	public static Major[] writeMajor(Collection tmajors){
		List list = new ArrayList();
		if (tmajors != null){
			Iterator iterator = tmajors.iterator();
            while (iterator.hasNext())
            {
                list.add(writeMajor((TMajor) iterator.next()));
            }
		}
		Major[] array = new Major[list.size()]; 
		return (Major[]) list.toArray(array);
	}
	
//	public static List<Major> writeMajor(Collection tmajors){
//		List list = new ArrayList();
//		if (tmajors != null){
//			Iterator iterator = tmajors.iterator();
//			while (iterator.hasNext())
//			{
//				list.add(writeMajor((TMajor) iterator.next()));
//			}
//		}
//		return list;
//	}
	
	public static TMajor readMajor(Major major){
		TMajor tmajor = new TMajor();
	    if (tmajor != null){
	    	tmajor.setId(major.getId());
	    	tmajor.setTInstitute(major.getTInstitute());
	    	tmajor.setName(major.getName());
	    	tmajor.setCode(major.getCode());
	    	tmajor.setModifiedTime(major.getModifiedTime());
	    	tmajor.setModifiedBy(major.getModifiedBy());
	    }
	    return tmajor;
    }
	
}
